#include "Player.h"
#include "Game.h"
#include "Swag.h"

Player::Player(Sprite* _ps, int _x, int _y, double _unitsPerSec) : mPoints(0), mBling(3.0) 
{
  Init(_ps,_x,_y,_unitsPerSec);
  this->sObjName = "Player";
}

// not used yet
/*
Player::Player(const Player& p) : posX(p.posX), posY(p.posY) {
}
*/

int Player::GetSwagCount(const sm_swag_type& type) const {
  int result = 0;
  if(mSwagCounters.find(type) != mSwagCounters.end()) { result = mSwagCounters.find(type)->second; }
  return result;
}

// TODO: fill this in with collision detection/reaction and possibly movement
void Player::Update(Game* pGame, Uint32 prevTick, Uint32 thisTick) {
}

void Player::PickupSwag(const Swag& theSwag) 
{
  // first, get points
  this->mPoints += theSwag.getPoints();

  // now, increment swag counter
  if(mSwagCounters.find(theSwag.getSwagType()) == mSwagCounters.end()) {
    mSwagCounters[theSwag.getSwagType()] = 0;
  }
  mSwagCounters[theSwag.getSwagType()]++;
  SetBling( GetBling() + 0.005*(double)theSwag.getPoints() );
}

void Player::SetBling(double _newBling) 
{
  if(_newBling < -5.0) mBling = -5.0;
  else if(_newBling > 5.0) mBling = 5.0;
  else mBling = _newBling;
}
